<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ include file="/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title>耀点100中台管理系统 商品管理</title>
<script src="<%=ServerValue.getMidContextPath()%>/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="../js/jquery.MultiFile.js" type="text/javascript" language="javascript"></script>  
<script language="javascript">
$().ready( function(){
	$('#saveBrand').click(function(){
		if(validate_data()==true){
			$("#branfForm").submit();
		}
	});

	 function validate_data(){
		 	var brand_result = true;
			if ($("#brandNameParam").val() == "" &&  $("#brandEnameParam").val() == ""){
			 	if ($("#brandNameParam").val() == "" ){
					alert("请输入中文名称");
					$("#brandNameParam").focus();
					brand_result == false;
					return false;
				}
				if ($("#brandEnameParam").val() == "" ){
					alert("请输入英文名称");
					$("#brandEnameParam").focus();
					brand_result == false;
					return false;
				}
			}
			if($("#brandNameParam").val().length+chineseCount($("#brandNameParam").val())>20){
				alert("限中文及數字(20字元以内)");
				$("#brandNameParam").focus();
				brand_result == false;
				return false;
			}
			if($("#brandEnameParam").val().length+chineseCount($("#brandEnameParam").val())>40){
				alert("限英文及數字(40字元以内))");
				$("#brandEnameParam").focus();
				brand_result == false;
				return false;
			}
			if($("#briefNameParam").val().length+chineseCount($("#briefNameParam").val())>20){
				alert("限中文及數字(20字元以内)");
				$("#briefNameParam").focus();
				brand_result == false;
				return false;
			}
			if ($("#briefNameParam").val() == "" ){
				alert("请输入簡短描述");
				$("#briefNameParam").focus();
				brand_result == false;
				return false;
			}
			/*
			if ($("#file-upload").val() == "" &&$("#brandimg").val()==""){
				alert("请输入品牌圖檔");
				$("#file-upload").focus();
				brand_result == false;
				return false;
			}
			*/
			
			
			if ( brand_result == false){ 
				return false
			}else{ return true;}
	 }

	 function chineseCount(word){
		    var length=0;
		    for(var cc=0;cc<word.length;cc++){
		       var c = word.charCodeAt(cc);
		      if (!(c>=32&&c<=126)) length++;
		    }
		    return length;
		}
	
});
</script>
</head>
<body>
<h1>商品管理- 品牌<br/>
<div class="f-link"><a href="<%=ServerValue.getMidContextPath()%>/brand/list.do">回品牌列表页</a></div>
</h1>
<s:form action="save.do" method="post" id="branfForm" enctype ="multipart/form-data"  class="P10">
<font color="red"><s:actionmessage escape="false"/></font>
	<table class="tb-data" width="100%">
		<tr>
			<th>品牌代码</th>			
			<td>${brand.brandId}</td>
		</tr>
		<tr>
			<th><span class='txt-rd'>*</span>中文名称</th>			
			<td><input type="text" name="brandNameParam"
				id="brandNameParam" value="${brand.brandName}" size="40"/>限中文及數字(20字元以内)、中文名称及英文名稱至少需填一项!</td>
		</tr>
		<tr>
			<th><span class='txt-rd'>*</span>英文名称</th>			
			<td><input type="text" name="brandEnameParam"
				id="brandEnameParam"  value="${brand.brandEname}" size="40"/>限英文及數字(40字元以内)、中文名称及英文名稱至少需填一项!</td>
		</tr>
		<tr>
			<th><span class='txt-rd'>*</span>簡短描述</th>			
			<td><input type="text" name="briefNameParam"
				id="briefNameParam" value="${brand.briefName}" size="40"/>限中英文及數字(20字元以内)ex.家庭音响领导品牌</td>
		</tr>
		<tr>
			<th>品牌同義詞</th>			
			<td><input type="text" name="brandSynonymParam"
				id="brandSynonymParam" size="100" value="${brand.brandSynonym}" />可逗号分隔最多10个同意词</td>
		</tr>
		<tr>
			<th>状态</th>			
			<td>
			<select id="brandStatusParam" name="brandStatusParam" gtbfieldid="10">
			    <option value="Y" <c-rt:if test="${brand.brandStatus=='Y' }">selected="selected"</c-rt:if>>启用</option>
			    <option value="N" <c-rt:if test="${brand.brandStatus=='N' }">selected="selected"</c-rt:if>>停用</option>
			</select>
			</td>
		</tr>
		<tr>
			<th>品牌圖檔</th>			
			<td>
			    <input type="file" name="upload" accept="gif|jpg|zip" class="multi {accept:'gif|jpg|zip', STRING:{ remove:'Remover',  selected:'Selecionado: $file', denied:'Invalido arquivo de tipo $ext!', duplicate:'Arquivo ja selecionado:\n$file!'}}" id="file-upload" size="50"/>
				必填、限110x40px(jpg/gif 5k以内)<br/>
				<c:if test="${brandId != null}">
				<img src="/static/brand/${brandId}/${brandId}.jpg"  onError="this.src='/PImg/blank_75.gif'" width="110" height="40" />
				</c:if>
				<input type="hidden" id="brandimg" value="${brand.brandImage}"/>
				</td>
		</tr>
		<tr>
			<th>品牌故事<br/><a href="/static/brand/brandstory_template.html" target="blank">(范例)</a></th>			
			<td>
				<div style="width:450px;"><span id="annContexTip" class="msg rn" style="display:none;"></span><br/></div>
				<div id="ann_ta_div" >
				<textarea name="brandStoryParam" id="ann_ta" cols="30" rows="5">${brandStoryParam}</textarea>
				<script type="text/javascript">
					CKEDITOR.replace('ann_ta');
					CKEDITOR.config.contentsCss = '/css/yaodian100_news.css';
				</script>
				</div>
			</td>
		</tr>
	
		<tr class="">
			<td><input type="hidden" name="brandId" value="${brandId}" /> <input
				type="button" id="saveBrand" value="確定" />
				
				<input type="button" onclick="window.location='list.do'" value="取消">
				</td>
		</tr>
	</table>
</s:form>

</body>
</html>


